Conversation
There was a problem hiding this comment.
Pull request overview
This pull request refactors PSF handling across autogalaxy to use Convolver instead of Kernel2D, updating call sites, type hints, FITS IO, plotting, and tests to consistently reference the underlying kernel via psf.kernel.
Changes:
- Replaced PSF types and construction from
Kernel2DtoConvolveracross core code paths and tests. - Updated PSF shape/value access patterns to use
psf.kernel.shape_native/psf.kernel.native(_for_fits). - Adjusted imaging simulation and aggregator FITS loading to build
Convolverfrom stored kernel arrays.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test_autogalaxy/profiles/light/test_snr.py | Updates SNR test PSF creation to Convolver.from_gaussian. |
| test_autogalaxy/operate/test_image.py | Refactors PSF setup to Convolver(kernel=...) and updates kernel shape access. |
| test_autogalaxy/imaging/test_simulator.py | Updates simulator tests to compare PSF kernels and construct Convolver PSFs. |
| test_autogalaxy/imaging/test_simulate_and_fit_imaging.py | Switches simulated PSF creation to Convolver.from_gaussian. |
| autogalaxy/profiles/light/snr/abstract.py | Updates psf type hint to Optional[aa.Convolver] and uses convolution via Convolver. |
| autogalaxy/profiles/light/linear/abstract.py | Updates linear objective function list to accept Optional[aa.Convolver] PSF. |
| autogalaxy/operate/image.py | Updates image blurring APIs to accept aa.Convolver and uses psf.kernel.shape_native for padding. |
| autogalaxy/imaging/simulator.py | Uses self.psf.kernel.shape_native when padding/trimming around convolution. |
| autogalaxy/imaging/model/plotter_interface.py | Writes PSF to FITS using dataset.psf.kernel.native_for_fits. |
| autogalaxy/galaxy/to_inversion.py | Updates inversion interface PSF type hint to Optional[aa.Convolver]. |
| autogalaxy/galaxy/galaxy.py | Updates galaxy SNR helper signature to accept Optional[aa.Convolver]. |
| autogalaxy/aggregator/imaging/imaging.py | Loads PSF kernel as Array2D and wraps it in aa.Convolver. |
| autogalaxy/init.py | Re-exports Convolver and removes the Kernel2D re-export. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from autoarray.structures.grids.uniform_2d import Grid2D # noqa | ||
| from autoarray.structures.grids.irregular_2d import Grid2DIrregular # noqa | ||
| from autoarray.operators.over_sampling.over_sampler import OverSampler # noqa | ||
| from autoarray.operators.convolver import Convolver |
There was a problem hiding this comment.
Convolver is imported for public re-export like the other autoarray symbols, but it’s missing the # noqa marker. Without it, linting (unused import) may fail; align with the surrounding imports by adding # noqa (or otherwise ensuring it’s referenced in this module).
| from autoarray.operators.convolver import Convolver | |
| from autoarray.operators.convolver import Convolver # noqa |
| def blurred_image_2d_from( | ||
| self, | ||
| grid: aa.Grid2D, | ||
| blurring_grid: aa.Grid2D, | ||
| psf: aa.Kernel2D = None, | ||
| psf: aa.Convolver = None, | ||
| xp=np, | ||
| ) -> aa.Array2D: |
There was a problem hiding this comment.
psf defaults to None but is passed unconditionally into _blurred_image_2d_from, which calls psf.convolved_image_from(...). Either make psf required (remove the = None default / update call sites) or change the annotation to Optional[aa.Convolver] and add a no-PSF path (e.g., return the unblurred image).
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This pull request refactors the codebase to replace the use of
Kernel2Das the point spread function (PSF) with a newConvolverclass throughout theautogalaxypackage. The changes update function signatures, internal logic, and tests to consistently useConvolver, and adjust all places where the PSF's shape or values are accessed to reference the underlying kernel withinConvolver. This improves clarity and modularity in PSF handling.Core refactor: PSF representation
Kernel2Das the PSF withConvolver, including function arguments, return types, and internal logic across the codebase. [1] [2] [3] [4] [5] [6] [7] [8] [9]psf.kernel.shape_nativeandpsf.kernel.native, ensuring correct usage with the newConvolverstructure. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Imaging and simulation logic
Convolverfrom kernel arrays, and updated relevant methods to accept and handleConvolverinstances. [1] [2]Convolverfor PSF operations, including convolution and plotting. [1] [2] [3]Test suite updates
Convolverinstead ofKernel2D, including creation viafrom_gaussianand access to kernel values and shapes. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]Cleanup and consistency
Kernel2Dfromautogalaxy/__init__.py.Convolverabstraction for improved maintainability. [1] [2]These changes collectively modernize the PSF handling in the codebase, making it more robust and easier to extend in the future.